/****************************************************************
 * Homework 5 Process class implementation file.
 * Author: Duncan Buell
 * Date last modified: 3 January 2010
 *
 * This is the most basic of data payload classes.  For a process
 * we need a process id 'pid', a start time 'startTime', an
 * execution time 'execTime', and a finish time 'finishTime'.
 *
 * We include a 'toString' function for easy display.
**/
#include <iostream>
#include <fstream>
#include <string>

#include "Process.h"

using namespace std;

/****************************************************************
 * Constructor.
**/
Process::Process()
{
}

/****************************************************************
 * Destructor.
**/
Process::~Process()
{
}

/*******************************************************************************
 * Accessor Function for process id
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
*******************************************************************************/
long Process::getPid(){
  return pid;
}

/*******************************************************************************
 * Mutator Function for process id
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
*******************************************************************************/
void Process::setPid(long what){
  pid = what;
}

/*******************************************************************************
 * Accessor Function for startTime
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
 * Note: Made a const function to allow it to be called by the constant process
 * parameter in the overloaded comparison function. Start Time is used as a
 * tiebreaker for comparing two Processes.
*******************************************************************************/
long Process::getStartTime() const{
  return startTime;
}

/*******************************************************************************
 * Mutator Function for startTime
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
*******************************************************************************/
void Process::setStartTime(long what){
  startTime = what;
}

/*******************************************************************************
 * Accessor Function for execTime
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
*******************************************************************************/
long Process::getExecTime(){
  return execTime;
}

/*******************************************************************************
 * Mutator Function for execTime
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
*******************************************************************************/
void Process::setExecTime(long what){
  execTime = what;
}

/*******************************************************************************
 * Accessor Function for FinishTime
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
 *
 * Note: This function is a const to allow it to be called by the const
 * parameter in the overloaded comparison operator. Finish time is 
 * computed by adding the startTime and the execTime.
*******************************************************************************/
long Process::getFinishTime() const{
  return (startTime +  execTime);
}

/*******************************************************************************
 * To string function for the Process class
 * Author: Andrew Shore
 * Date Last Modified: 23 March 2010
 *
 * Returns a formatted string containing the information of the process
 * class. Makes use of the Format functions in Utils.cpp to allow the long
 * class variables to be assigned to a string and also to put the information
 * into columns. The pid,startTime,execTime, and finishTime are put into the
 * string.
 *
 * Parameters: none
 *
 * Output: none
 *
 * Returns: A string version of this process class
*******************************************************************************/
string Process::toString(){
  string s;
  s += Utils::Format("Pid:" , 7);
  s += Utils::Format(pid , 7);
  s += Utils::Format("   StartTime:" , 7);
  s += Utils::Format(startTime , 7);
  s += Utils::Format("   ExecTime:", 7);
  s += Utils::Format(execTime , 7);
  s += Utils::Format("   FinishTime:" , 7);
  s += Utils::Format(getFinishTime() , 7);
  
  
  return s;
}
